package com.imau.mapper;

import com.imau.bean.SysDept;
import io.mybatis.mapper.Mapper;
import io.mybatis.mapper.base.EntityProvider;
import io.mybatis.provider.Caching;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Lang;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface SysDeptMapper extends Mapper<SysDept,String>
{
    @Lang(Caching.class)
    @InsertProvider(
            type = EntityProvider.class,
            method = "insert"
    )
    @Options(
            useGeneratedKeys = false,//不使用数据库的自动主键生成
            keyProperty = "tid"
    )
    <S extends SysDept> int insert(S entity);

    SysDept selectByKey(@Param("did") String did);

    /**
     * 修改子元素关系
     *
     * @param depts 子元素
     * @return 结果
     */
    public int updateDeptChildren(@Param("depts") List<SysDept> depts);
}
